package ro.pub.cs.hwchecker.comm.client.req;

public class CheckerRequestException extends Exception {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	public static final int CODE_OK = 0;	
	public static final int CODE_GENERIC_ERROR = 1;
	public static final int CODE_NOT_CONNECTED = 2;
	public static final int CODE_INVALID_REQ = 3;
	
	private int checkerCode = 0;
	
	public static CheckerRequestException errorNotConnected(Throwable cause) {
		return new CheckerRequestException(CODE_NOT_CONNECTED, 
				"Could not establish the connection", cause);
	}
	
	public static CheckerRequestException errorInvalidRequest() {
		return new CheckerRequestException(CODE_INVALID_REQ, 
				"Invalid request");
	}
	
	public static CheckerRequestException errorInvalidRequest(Throwable cause) {
		return new CheckerRequestException(CODE_INVALID_REQ,
				"Invalid request", cause);
	}
	
	public static CheckerRequestException errorGeneric() { 
		return new CheckerRequestException(CODE_GENERIC_ERROR, "Error");
	}

	public CheckerRequestException() {
		
	}

	public CheckerRequestException(int code, String msg) {
		super(msg);
		this.checkerCode = code;
	}

	public CheckerRequestException(Throwable cause) {
		super(cause);
	}

	public CheckerRequestException(int code, String msg, Throwable cause) {
		super(msg, cause);
		this.checkerCode = code;
	}

	public int getCheckerCode() {
		return checkerCode;
	}
}
